package com.xdtech.sys.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.sql.Timestamp;

import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.sys.model.Resource;

import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2015-03-18 13:53:54
 * @since 1.0
 * @see
 */
public class ResourceItem implements Serializable{
	private static final long serialVersionUID = 1L;
	private Long id;
	@GridColumn(title="资源类型",width=100)
	private String type;
	@GridColumn(title="资源key",width=100)
	private String key;

	public void setId(Long id) {
		this.id = id;
	}
	public Long getId() {
		return id;
	}
	
	public void setType(String type) {
		this.type = type;
	}
	public String getType() {
		return type;
	}
	
	public void setKey(String key) {
		this.key = key;
	}
	public String getKey() {
		return key;
	}
	
	/**
	 * 根据model构建vo
	 * 
	 * @author max
	 * @return
	 */
	public static ResourceItem createItem(Resource resource) {
		ResourceItem resourceItem = new ResourceItem();
		BeanUtils.copyProperties(resourceItem, resource);
		//自定义属性设置填充
		return resourceItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<ResourceItem> createItems(List<Resource> resources) {
		List<ResourceItem> resourceItems = new ArrayList<ResourceItem>();
		for (Resource resource : resources) {
			resourceItems.add(createItem(resource));
		}
		return resourceItems;
	}
}
